package com.hanhanxiaochong.zhongxiangchuanmei.view.home.act;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hanhanxiaochong.zhongxiangchuanmei.R;
import com.hanhanxiaochong.zhongxiangchuanmei.util.MessageEvent;
import com.hanhanxiaochong.zhongxiangchuanmei.view.base.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;
import de.greenrobot.event.EventBus;

/**
 * Author : 贾桐
 * E-mail : 653773284@qq.com
 * Time   : 2018/5/2.
 * Desc   : 预约成功act
 */

public class AppointmentSuccessActivity extends BaseActivity {

    @BindView(R.id.img_left)
    ImageView imgLeft;
    @BindView(R.id.txt_title)
    TextView txtTitle;
    @BindView(R.id.txt_code)
    TextView txtCode;
    @BindView(R.id.txt_state)
    TextView txtState;

    private String serviceCode;

    public static Intent createIntent(Context context, String serviceCode) {
        Intent intent = new Intent(context, AppointmentSuccessActivity.class);
        intent.putExtra("serviceCode", serviceCode);
        return intent;
    }

    @Override
    protected void initView() {
        setContentView(R.layout.activity_appointment_success);
    }

    @Override
    protected void initPresenter() {

    }

    @Override
    protected void init() {
        serviceCode = getIntent().getStringExtra("serviceCode");
        setTopView();
        EventBus.getDefault().post(new MessageEvent("pay_success"));
    }

    private void setTopView() {
        imgLeft.setImageResource(R.mipmap.icon_close_black);
        if (serviceCode != null) {
            txtTitle.setText("预约成功");
            txtCode.setText("体验码:" + serviceCode);
        } else {
            txtTitle.setText("下单成功");
            txtState.setText("下单成功");
            txtCode.setVisibility(View.GONE);
        }
    }

    @OnClick({R.id.ll_leftview})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_leftview:
                finish();
                break;
        }
    }
}
